package mo.offer_special;

public class L018 {

    public boolean isPalindrome(String s) {
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if (Character.isDigit(c) || Character.isAlphabetic(c)) {
                builder.append(c);
            }
        }
        String s1 = builder.toString().toLowerCase();
        for (int i = 0; i < s1.length(); i++) {
            if (s1.charAt(i) != s1.charAt(s1.length()-1-i)) {
                return false;
            }
        }
        return true;
    }

    public static void main(String[] args) {
        L018 test = new L018();
        System.out.println(test.isPalindrome("A man, a plan, a canal: Panama"));
    }

}
